import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.XmlWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.FrameworkServlet;
import org.springframework.web.servlet.HttpServletBean;
import org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping;
import org.springframework.web.servlet.handler.AbstractHandlerMethodMapping;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

/**
 * <pre>
 * 前言：【spring-web与spring-webmvc】
 *  ● spring-web模块：提供了与Web相关的通用支持和功能、与ServletAPI的集成、处理HTTP请求/响应有关的类
 *         包括核心的Web层抽象，如：WebApplicationInitializer、WebApplicationContext、DispatcherServlet等
 *         提供了对Restful Web服务的支持(包括：HTTP消息转换器、URI模板变量的解析/处理等)
 *
 *  ● spring-webmvc模块：构建在spring-web模块之上，提供了基于MVC(Model-View-Controller)模式的Web应用程序开发支持
 *         - 提供了：强大的处理器适配器(HandlerAdapter)、视图解析器(ViewResolver)等机制
 *         - 包括：控制器(Controller)的定义和处理、视图(View)的解析和渲染、请求映射和处理等
 *         - 支持：注解驱动的控制器和请求处理，如：@Controller、@RequestMapping、@RequestParam等
 *
 * 【SpringMVC源码学习】
 *
 * 1、web容器启动
 *  1)创建父容器：
 *   @see ContextLoaderListener#initWebApplicationContext
 * 	     @see ContextLoader#createWebApplicationContext {@link XmlWebApplicationContext}
 *  2)创建子容器：
 *   @see HttpServletBean#init
 *       @see FrameworkServlet#initServletBean
 *            @see FrameworkServlet#initWebApplicationContext
 *                @see FrameworkServlet#createWebApplicationContext
 *  3)servlet初始化：
 *   @see FrameworkServlet.ContextRefreshListener#onApplicationEvent(ContextRefreshedEvent)
 *       # 初始化SringMVC的九大组件
 *   	 @see DispatcherServlet#onRefresh(ApplicationContext)
 *  4)解析处理器映射：url与Controller映射
 *   @see ApplicationContextAware#setApplicationContext
 *       @see AbstractDetectingUrlHandlerMapping#initApplicationContext()
 *     	    @see AbstractDetectingUrlHandlerMapping#detectHandlers()
 *     	    @see InitializingBean#afterPropertiesSet()
 *   @see AbstractHandlerMethodMapping#afterPropertiesSet()
 *       @see AbstractHandlerMethodMapping#processCandidateBean
 *           @see RequestMappingHandlerMapping#isHandler
 *           @see AbstractHandlerMethodMapping#detectHandlerMethods
 *             @see RequestMappingHandlerMapping#getMappingForMethod
 *             @see RequestMappingHandlerMapping#registerHandlerMethod
 * 2、执行流程：
 *  @see DispatcherServlet#doDispatch
 *
 * 3、SpringBoot自动配置：
 *  @see EnableWebMvc
 *      @see DelegatingWebMvcConfiguration
 *          @see WebMvcConfigurationSupport：向容器中注册了SringMVC的各个组件
 *              @see WebMvcConfigurationSupport#requestMappingHandlerMapping
 *             	    @see WebMvcConfigurationSupport#getInterceptors
 * </pre>
 *
 *
 * @author：mdw
 * @date: 2024/1/4
 */
public class SourceCode {

	public static void main(String[] args) {
		importClass();
	}

	private static void importClass() {
		RequestMappingHandlerMapping requestMappingHandlerMapping;
		AbstractHandlerMethodMapping abstractHandlerMethodMapping;
		EnableWebMvc enableWebMvc;
		WebMvcConfigurationSupport webMvcConfigurationSupport;
		DelegatingWebMvcConfiguration delegatingWebMvcConfiguration;
		ApplicationContextAware applicationContextAware;
		AbstractDetectingUrlHandlerMapping abstractDetectingUrlHandlerMapping;
		DispatcherServlet dispatcherServlet;
		XmlWebApplicationContext xmlWebApplicationContext;
		ContextLoader contextLoader;
		ContextLoaderListener contextLoaderListener;
	}
}
